package artid.com.arttogoa;
import artid.com.arttogoa.R;

import artid.com.arttogoa.barcode.Cache;
import artid.com.arttogoa.parser.RecordDetailList;
import artid.com.arttogoa.volley.BitmapCache;
import artid.com.arttogoa.volley.VolleyBasic;
import artid.com.arttogoa.volley.VolleyCallback;
import artid.com.arttogoa.volley.VolleyData;
import artid.com.arttogoa.volley.VolleyMap;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
import com.android.volley.toolbox.ImageLoader.ImageListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 
 * 
 * 项目名称：ArtworkArtA 类名称：FbDynamicActivity 类描述：发布动态 创建人：耿卫斌 创建时间：2016年5月16日
 * 下午1:30:35
 * 
 */
public class FbDynamicActivity extends BaseActivity implements OnClickListener {
	String id, state, tittle, imgurl, realdetail;
	private TextView fb_detail;
	private TextView reStatus;
	private ImageView reComplete, redeail_img;
	private ImageLoader mImageLoader;
	private Button quxiao, queren;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_fb_dynamic);
		setContent(this, getIntent());
		initView();
	}

	private void initView() {
		mContext = this;
		setBack();
		RequestQueue mQueue = Volley.newRequestQueue(mContext);
		mImageLoader = new ImageLoader(mQueue, new BitmapCache());
		id = getIntent().getExtras().getString("id");
		state = getIntent().getExtras().getString("state");
		tittle = getIntent().getExtras().getString("tittle");
		imgurl = getIntent().getExtras().getString("imgurl");
		realdetail = getIntent().getExtras().getString("realdetail");
		mTittle = (TextView) findViewById(R.id.title_text);
		mFbText = (TextView) findViewById(R.id.title_fb);
		fb_detail = (TextView) findViewById(R.id.fb_detail);
		reComplete = (ImageView) findViewById(R.id.redetail_complete);
		redeail_img = (ImageView) findViewById(R.id.redeail_img);
		reStatus = (TextView) findViewById(R.id.redetail_status);
		quxiao = (Button) findViewById(R.id.quxiao);
		queren = (Button) findViewById(R.id.queding);
		mTittle.setText(tittle);
		if (state.equals("-1")) {
			reComplete.setVisibility(View.GONE);
			reStatus.setVisibility(View.VISIBLE);
			reStatus.setText("未通过审核");
		} else if (state.equals("2")) {
			reComplete.setVisibility(View.VISIBLE);
			reStatus.setVisibility(View.GONE);
		} else if (state.equals("1")) {
			reComplete.setVisibility(View.GONE);
			reStatus.setVisibility(View.VISIBLE);
			reStatus.setText("审核中");
		}
		ImageListener listener = ImageLoader.getImageListener(redeail_img,
				R.drawable.yspba_img_mor, R.drawable.yspba_img_mor);
		mImageLoader.get(imgurl, listener);
		fb_detail.setText(realdetail);
		quxiao.setOnClickListener(this);
		queren.setOnClickListener(this);
		mBack.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.quxiao:
			finish();
			break;
		case R.id.queding:
			fbNew();
			break;

		default:
			break;
		}
	}

	private void fbNew() {
		VolleyBasic.getInstance(FbDynamicActivity.this).post(
				Cache.dynamicdelivery,
				VolleyMap.getInstance().recordDetaillist(id),
				RecordDetailList.class, new VolleyCallback() {

					@Override
					public void onSuccess(VolleyData vd) {

						Intent intent = new Intent(FbDynamicActivity.this,
								ArtDynamicActivity.class);
						startActivity(intent);
						finish();

					}

					@Override
					public void onError(VolleyError volleyError) {
						
					}
				});
	}

}
